import requests

from api import SYSTEM_URL, SESSION


class UploadUserAvatar:

    def __init__(self):
        self.url = SYSTEM_URL + "/apis/api.console.halo.run/v1alpha1/users/"
        self.headers = {
            "Cookie": SESSION
        }

    def upload_user_avatar(self, file, username):

        files = [
            ("file", file)
        ]
        response = requests.post(self.url + str(username) + "/avatar", headers=self.headers, files=files)
        return response
